package catalina.container;

import catalina.connection.Request;
import catalina.connection.Response;

import java.util.Properties;

public class StandardWrapper extends ContainerBase {

    private Servlet servlet;

    public Servlet getServlet() {
        return servlet;
    }

    public void setServlet(Servlet servlet) {
        this.servlet = servlet;
    }

    @Override
    public void initInternal() {
        Properties properties = getProperties();
        if(properties != null){
           this.servlet =(Servlet) properties.get("servlet");
        }
    }

    @Override
    public void startInternal() {

    }

    @Override
    public void stopInternal() {

    }

    @Override
    public void destroyInternal() {

    }

    @Override
    public void service(Request request, Response response) {
        try {
            servlet.service(request,response);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
